﻿using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Serialization;
using ihongma.Common;

namespace ihongma.Web.tools
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    //[WebService(Namespace = "http://tempuri.org/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class color : IHttpHandler
    {
        BLL.color bll = new ihongma.BLL.color();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = DTRequest.GetQueryString("action");
            string ret=string.Empty;

            switch (action)
            {
                case "add": //加载频道管理菜单
                    ret = add(DTRequest.GetQueryString("name")).ToString();
                    break;
                case "delete": //验证频道名称是否重复
                    ret = delete(DTRequest.GetQueryInt("id")).ToString();
                    break;
                //case "list": //删除系统模型菜单
                //    ret = getlist();
                //    break;
            }



            context.Response.Write(ret);
        }
        public bool add(string name)
        {
            Model.color model = new ihongma.Model.color();
            model.colorvalue = name;
            model.name = name;
            model.hits = 1;
            return bll.Add(model);

        }
        private bool delete(int id)
        {
            return bll.Delete(id);
        }
        private string list()
        {
            JavaScriptSerializer jserializer = new JavaScriptSerializer();
            return jserializer.Serialize(bll.GetModelList(""));
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
